import { AfterViewInit, Component, Input, OnInit, TemplateRef } from '@angular/core';

export class ColumnContext<T = unknown> {
  public $implicit: T = null;
  public data?: T = null;
  public column?: T = null;
}

let columnKey = 0;

@Component({
  selector: 'bz-table-column',
  template: '',
  exportAs: 'bzTableColumn'
})
export class TableColumnComponent implements OnInit, AfterViewInit {

  nzWidth: number;
  nzLeft: number;
  nzRight: number;
  id: number;
  // columnContext = new ColumnContext();
  /** 值绑定 */
  @Input() dataField: string;
  /** 标题 */
  @Input() caption: string;
  /** 文本位置 */
  @Input() alignment: 'left' | 'right' | 'center';
  /** 自定义返回值 */
  @Input() customizeText: ((itemInfo: { value?: string | number | Date, valueText?: string }) => string);
  /** 隐藏或显示 */
  @Input() visible = true;
  /** 排序 */
  @Input() allowSorting: boolean;
  /** 自定义td模版 */
  @Input() cellTemplate: ColumnContext | null;
  /** 自定义th模版 */
  @Input() headerCellTemplate: ColumnContext | null;
  /** 宽度 */
  @Input() width: number;
  /** 定位 */
  @Input() fixed = false;
  /** 定位位置 */
  @Input() fixedPosition: 'left' | 'right' = 'left';

  constructor() {

  }

  ngAfterViewInit(): void {

  }

  ngOnInit() {
    this.id = columnKey++;
  }

}
